package com.ajk.server.service.impl;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;

import com.ajk.server.dao.PartientEventExtMapper;
import com.ajk.server.model.PartientEventExt;
import com.ajk.server.model.query.PartientEventExtQuery;
import com.ajk.server.service.PartientEventExtService;

/**
 * 用户健康数据扩展表  <br>
 * t_partient_event_ext <br>
 * v1.0 2016-04-20
 */
@Service
public class PartientEventExtServiceImpl implements PartientEventExtService {

	private static final Logger logger = LoggerFactory.getLogger(PartientEventExtServiceImpl.class);
	
	@Autowired
	private PartientEventExtMapper partientEventExtMapper;

	/**
	 * 新增用户健康数据扩展表
	 */
	@Transactional
	public Integer addPartientEventExt(PartientEventExt partientEventExt){
		//dealwith
		//校验
		partientEventExtMapper.insertPartientEventExt(partientEventExt);
		return partientEventExt.getId();
	}

	/**
	 * 修改用户健康数据扩展表
	 */
	@Transactional
	public Integer updatePartientEventExt(PartientEventExt partientEventExt){
		partientEventExtMapper.updatePartientEventExt(partientEventExt);
		return partientEventExt.getId();
	}

	/**
	 * 搜索用户健康数据扩展表
	 */
	public List<PartientEventExt> queryPartientEventExtByQuery(PartientEventExtQuery query){
		List<PartientEventExt> result = partientEventExtMapper.findByQuery(query);
		if(!CollectionUtils.isEmpty(result)){
			for(PartientEventExt partientEventExt:result){
				partientEventExt.dealWith();	
			}
		}
		return result;
	}

	/**
	 * 通过ID查询用户健康数据扩展表
	 */
	public PartientEventExt queryPartientEventExtById(Integer id){
		PartientEventExt partientEventExt = partientEventExtMapper.findById(id);
		if(partientEventExt!=null){
			partientEventExt.dealWith();
		}

		return partientEventExt;	
	}
}	